<template>
  <div class="login-container">
    <el-card class="login-card">
      <h2 class="login-title">Login</h2>
      <el-form :model="loginForm" @submit.prevent="onSubmit" ref="loginForm" class="login-form">
        <el-form-item prop="username">
          <el-input v-model="loginForm.username" placeholder="Username"></el-input>
        </el-form-item>
        <el-form-item prop="password">
          <el-input v-model="loginForm.password" placeholder="Password" type="password"></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="onSubmit" class="login-button">Login</el-button>
        </el-form-item>
        <el-form-item>
          <el-link href="#" class="forgot-link">Forgot Password?</el-link>
        </el-form-item>
      </el-form>
    </el-card>
  </div>
</template>

<script>
export default {
  name: 'Login',
  data() {
    return {
      loginForm: {
        username: '',
        password: '',
      },
    };
  },
  methods: {
    onSubmit() {
      // 模拟登录逻辑
      if (this.loginForm.username && this.loginForm.password) {
        this.$emit('login');
      } else {
        this.$message.error('Please enter username and password');
      }
    },
  },
};
</script>

<style scoped>
.login-container {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  background: linear-gradient(to right, #4facfe, #00f2fe);
}

.login-card {
  width: 400px;
  padding: 40px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.login-title {
  text-align: center;
  margin-bottom: 30px;
  color: #333;
  font-weight: bold;
}

.login-form {
  display: flex;
  flex-direction: column;
}

.login-button {
  width: 100%;
  margin-top: 20px;
}

.forgot-link {
  display: block;
  text-align: center;
  margin-top: 10px;
  color: #409eff;
}
</style>
